import { useModel } from "umi";

import AddBranchInstitution from "../components/branch/Add";
import EditBranchInstitution from "../components/branch/Edit";

import AddBranchInstitutionDepartment from "../components/branch/AddDepartment";
import EditBranchInstitutionDepartment from "../components/branch/EditDepartment";

import AddInstitutionPosition from "../components/institution/AddPosition";
import AddInstitutionMember from "../components/institution/AddMember";

import AddProjectInstitution from "../components/project/Add";
import EditProjectInstitution from "../components/project/Edit";

import AddProjectInstitutionDepartment from "../components/project/AddDepartment";
import EditProjectInstitutionDepartment from "../components/project/EditDepartment";

import AddSpecialityInstitution from "../components/speciality/Add";
import EditSpecialityInstitution from "../components/speciality/Edit";

import AddInterestInstitution from "../components/interest/Add";
import EditInterestInstitution from "../components/interest/Edit";

import AddActivityInstitution from "../components/activity/Add";
import EditActivityInstitution from "../components/activity/Edit";

const useHelperInstitution = () => {
    const { setModalVisible, setModalTitle, setModalWidth, setModalComponent, setModalStyle } = useModel("global.modal");

    const openAddBranchInstitutionModal = ({ reloadData }) => {
        setModalTitle(`添加分支机构`);
        setModalVisible(true);
        setModalWidth(650);
        setModalComponent(<AddBranchInstitution reloadData={reloadData} />);
    };

    const openEditBranchInstitutionModal = ({ institution, reloadData }) => {
        setModalTitle(`编辑分支机构信息`);
        setModalVisible(true);
        setModalWidth(650);
        setModalComponent(<EditBranchInstitution institution={institution} reloadData={reloadData} />);
    };

    const openAddBranchInstitutionDepartmentModal = ({ institution, reloadData }) => {
        setModalTitle(`添加分支机构部门`);
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<AddBranchInstitutionDepartment institution={institution} reloadData={reloadData} />);
    };

    const openEditBranchInstitutionDepartmentModal = ({ department, reloadData }) => {
        setModalTitle(`编辑分支机构部门信息`);
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<EditBranchInstitutionDepartment department={department} reloadData={reloadData} />);
    };

    const openAddInstitutionPositionModal = ({ institutionPositions, institution, reloadData }) => {
        setModalTitle(`添加岗位人员`);
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<AddInstitutionPosition institutionPositions={institutionPositions} institution={institution} reloadData={reloadData} />);
    };

    const openAddInstitutionMemberModal = ({ institutionMembers, institution, reloadData }) => {
        setModalTitle(`添加成员`);
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<AddInstitutionMember institutionMembers={institutionMembers} institution={institution} reloadData={reloadData} />);
    };

    const openAddProjectInstitutionModal = ({ reloadData }) => {
        setModalTitle(`添加项目组`);
        setModalVisible(true);
        setModalWidth(650);
        setModalComponent(<AddProjectInstitution reloadData={reloadData} />);
    };

    const openEditProjectInstitutionModal = ({ institution, reloadData }) => {
        setModalTitle(`编辑项目组信息`);
        setModalVisible(true);
        setModalWidth(650);
        setModalComponent(<EditProjectInstitution institution={institution} reloadData={reloadData} />);
    };

    const openAddProjectInstitutionDepartmentModal = ({ institution, reloadData }) => {
        setModalTitle(`添加项目组部门`);
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<AddProjectInstitutionDepartment institution={institution} reloadData={reloadData} />);
    };

    const openEditProjectInstitutionDepartmentModal = ({ department, reloadData }) => {
        setModalTitle(`编辑项目组部门信息`);
        setModalVisible(true);
        setModalWidth(500);
        setModalComponent(<EditProjectInstitutionDepartment department={department} reloadData={reloadData} />);
    };

    const openAddSpecialityInstitutionModal = ({ reloadData }) => {
        setModalTitle(`添加专业组`);
        setModalVisible(true);
        setModalWidth(650);
        setModalComponent(<AddSpecialityInstitution reloadData={reloadData} />);
    };

    const openEditSpecialityInstitutionModal = ({ institution, reloadData }) => {
        setModalTitle(`编辑专业组信息`);
        setModalVisible(true);
        setModalWidth(650);
        setModalComponent(<EditSpecialityInstitution institution={institution} reloadData={reloadData} />);
    };

    const openAddInterestInstitutionModal = ({ reloadData }) => {
        setModalTitle(`添加兴趣组`);
        setModalVisible(true);
        setModalWidth(650);
        setModalComponent(<AddInterestInstitution reloadData={reloadData} />);
    };

    const openEditInterestInstitutionModal = ({ institution, reloadData }) => {
        setModalTitle(`编辑兴趣组信息`);
        setModalVisible(true);
        setModalWidth(650);
        setModalComponent(<EditInterestInstitution institution={institution} reloadData={reloadData} />);
    };

    const openAddActivityInstitutionModal = ({ reloadData }) => {
        setModalTitle(`添加活动组`);
        setModalVisible(true);
        setModalWidth(650);
        setModalComponent(<AddActivityInstitution reloadData={reloadData} />);
    };

    const openEditActivityInstitutionModal = ({ institution, reloadData }) => {
        setModalTitle(`编辑活动组信息`);
        setModalVisible(true);
        setModalWidth(650);
        setModalComponent(<EditActivityInstitution institution={institution} reloadData={reloadData} />);
    };

    return {
        openAddBranchInstitutionModal,
        openEditBranchInstitutionModal,
        openAddBranchInstitutionDepartmentModal,
        openEditBranchInstitutionDepartmentModal,
        openAddInstitutionPositionModal,
        openAddInstitutionMemberModal,
        openAddProjectInstitutionModal,
        openEditProjectInstitutionModal,
        openAddProjectInstitutionDepartmentModal,
        openEditProjectInstitutionDepartmentModal,
        openAddSpecialityInstitutionModal,
        openEditSpecialityInstitutionModal,
        openAddInterestInstitutionModal,
        openEditInterestInstitutionModal,
        openAddActivityInstitutionModal,
        openEditActivityInstitutionModal,
    };
};

export default useHelperInstitution;
